<?php
/**
 * Reference presenter.
 */
class ReferencePresenter extends BasePresenter
{
    public function renderDefault($id = null, $makler = null) {
        $referenceModel = new ReferenceModel($this->db);   
        if ($id !== null) {
            $referenceModel->where("agent = ?", $id)->order("ref_order");
            $this->template->activeAgent = $id;
        } else {
            $referenceModel->order("id DESC");
        }
        $this->template->references = $referenceModel;
        
        $agentModel = new AgentModel($this->db);                
        $this->template->agents = $agentModel;        
    }    
    
    public function renderRezervovane() {
        $estateModel = new EstateModel($this->db);
        $this->template->estates = $estateModel->where("deleted", 0)->where("commission_status", CommissionStatus::REZERVACE)->order("registration_number DESC");
    }
            
    public function renderZrealizovane() {
        $estateModel = new EstateModel($this->db);
        $this->template->estates = $estateModel->where("deleted", 0)->where("commission_status", CommissionStatus::ZREALIZOVANO)->order("registration_number DESC");
    }
}
